## [1] "Run Completed at 2018-02-15 07:09:02"

Absence data

Models

Random Baseline

## sink("models/SpeciesIdentity.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #observation
##     logit(s[x])<-alpha[Bird[x],Plant[x]]
##     Yobs[x] ~ dbern(s[x])
##     
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       logit(snew[x])<-alpha[NewBird[x],NewPlant[x]]
##       Ynew_pred[x]~dbern(snew[x])
##     
##       #Assess fit, proportion of corrected predicted observations
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
## 
##     }
##     
##     #Priors
## 
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
## 
##         #Intercept
##         #logit prior, then transform for plotting
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
## 
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 0
##    Unobserved stochastic nodes: 50408
##    Total graph size: 206884
## 
## Initializing model

Assess Convergence

Species Identity

## sink("models/SpeciesIdentity.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #observation
##     logit(s[x])<-alpha[Bird[x],Plant[x]]
##     Yobs[x] ~ dbern(s[x])
##     
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       logit(snew[x])<-alpha[NewBird[x],NewPlant[x]]
##       Ynew_pred[x]~dbern(snew[x])
##     
##       #Assess fit, proportion of corrected predicted observations
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
## 
##     }
##     
##     #Priors
## 
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
## 
##         #Intercept
##         #logit prior, then transform for plotting
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
## 
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 19724
##    Total graph size: 206884
## 
## Initializing model

Assess Convergence

Detectability + Species Identity

## sink("models/SpeciesIdentity_Detect.jags")
## cat("
##     model {
##     
##     #True interaction probability for each bird, plant
##     for (i in 1:Birds){
##       for(j in 1:Plants){
##           logit(s[i,j])<-alpha[i,j]
##         }
##     }
## 
##     #Observation Model
##     for (x in 1:Nobs){
##       
##       #Detection Process
##       z[x] ~ dbern(detect[Bird[x]]) 
##       
##       #Observation
##       p[x]<-z[x] * s[Bird[x],Plant[x]]
##       Yobs[x] ~ dbern(p[x])
##     }
##     
##     #Assess Model Fit - Predict remaining data
## 
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       znew[x] ~ dbern(detect[NewBird[x]])
##       pnew[x] <- znew[x]*s[NewBird[x],NewPlant[x]]
##   
##       #Predicted observation
##       Ynew_pred[x]~dbern(pnew[x])
##       
##       #Assess fit, proportion of corrected predicted links
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##       logit(detect[x])<-dcam[x]
##       dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
##         #Logit Intercept
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
##     
##     #OBSERVATION PRIOR
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 69274
##    Total graph size: 305983
## 
## Initializing model

Assess Convergence

# Species Identity + Detection + Elevation

## sink("models/SpeciesIdentity_Detect_Elevation.jags")
## cat("
##     model {
##     
##     #Ecological Process Model
##     #True State for each bird, plant, camera
##     for (i in 1:Birds){
##       for(j in 1:Plants){
##         for(k in 1:Cameras){
##           
##           #Occurrence 
##           logit(psi[i,j,k])<-alpha_occ[i] + beta_occ[i] * elevation[k] + beta2_occ[i] * elevation[k]^2
##           occ[i,j,k] ~ dbern(psi[i,j,k])
## 
##           #Interaction
##           logit(s[i,j,k])<-alpha[i,j]
## 
##           #Conditional probability of interaction|occurrence
##           rho[i,j,k] <- s[i,j,k] * occ[i,j,k]
##         }
##       }
##     }
##     
##     #Observation Model
##     for (x in 1:Nobs){
##     
##     #Detection Process
##     z[x] ~ dbern(detect[Bird[x]]) 
##     
##     #Observation, conditional on detection and occurrence.
##     p[x]<-z[x] * rho[Bird[x],Plant[x],Camera[x]]
##     Yobs[x] ~ dbern(p[x])
##     
##     #Observed discrepancy
##     #E[x]<-abs(Yobs[x]- s[Bird[x],Plant[x],Camera[x]])
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     
##     for(x in 1:Nnewdata){
##     
##     #Generate prediction
##     znew[x] ~ dbern(detect[NewBird[x]])
##     pnew[x] <- znew[x]*rho[NewBird[x],NewPlant[x],NewCamera[x]]
##     
##     #Predicted observation
##     Ynew_pred[x]~dbern(pnew[x])
##     
##     #Assess fit, proportion of corrected predicted links
##     Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
## 
##     #Occurrence model
##     for(x in 1:Birds){
##     alpha_occ[x] ~ dnorm(0,0.386)
##     beta_occ[x] ~ dnorm(0,0.386)
##     beta2_occ[x] ~ dnorm(0,0.386)
##     }
## 
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##     logit(detect[x])<-dcam[x]
##     dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     for (i in 1:Birds){
##     for (j in 1:Plants){
##     #Intercept
##     #logit prior, then transform for plotting
##     alpha[i,j] ~ dnorm(0,0.386)
##     }
##     }
##     
##     #Observation group prior
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive check
##     fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 625494
##    Total graph size: 1492420
## 
## Initializing model
## 
##      user    system   elapsed 
## 10625.799    55.259 10787.046

Assess Convergence

Predicted elevation ranges

Model Comparison

By Species

Detectability

Proportion of predicted observations

Predicted network statistics

Dashed line is the observed network from the time-series.

Comparing predictors

How much to do here.

Predicted betadiversity

Split data into wet (November - May) versus dry season (June - October)

Change in the probability of species interaction

## sink("models/SpeciesIdentity_Detect_Elevation_Beta.jags")
## cat("
##     model {
##     
##     #Ecological Process Model
##     #True State for each bird, plant, camera
##     for (i in 1:Birds){
##     for(j in 1:Plants){
##     for(k in 1:Cameras){
##     
##     #Occurrence 
##     logit(psi[i,j,k])<-alpha_occ[i] + beta_occ[i] * elevation[k] + beta2_occ[i] * elevation[k]^2
##     occ[i,j,k] ~ dbern(psi[i,j,k])
##     
##     #Interaction
##     logit(s[i,j,k])<-alpha[i,j] + beta_season[i,j] *Season[k]
##     
##     #Conditional probability of interaction|occurrence
##     rho[i,j,k] <- s[i,j,k] * occ[i,j,k]
##     }
##     }
##     }
##     
##     #Observation Model
##     for (x in 1:Nobs){
##     
##     #Detection Process
##     z[x] ~ dbern(detect[Bird[x]]) 
##     
##     #Observation, conditional on detection and occurrence.
##     p[x]<-z[x] * rho[Bird[x],Plant[x],Camera[x]]
##     Yobs[x] ~ dbern(p[x])
##     
##     #Observed discrepancy
##     #E[x]<-abs(Yobs[x]- s[Bird[x],Plant[x],Camera[x]])
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     
##     for(x in 1:Nnewdata){
##     
##     #Generate prediction
##     znew[x] ~ dbern(detect[NewBird[x]])
##     pnew[x] <- znew[x]*rho[NewBird[x],NewPlant[x],NewCamera[x]]
##     
##     #Predicted observation
##     Ynew_pred[x]~dbern(pnew[x])
##     
##     #Assess fit, proportion of corrected predicted links
##     Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
##     
##     #Occurrence model
##     for(x in 1:Birds){
##     alpha_occ[x] ~ dnorm(0,0.386)
##     beta_occ[x] ~ dnorm(0,0.386)
##     beta2_occ[x] ~ dnorm(0,0.386)
##     }
##     
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##     logit(detect[x])<-dcam[x]
##     dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     for (i in 1:Birds){
##     for (j in 1:Plants){
##         #Interaction probability
##         alpha[i,j] ~ dnorm(0,0.386)
##         #Effect of season
##         beta_season[i,j] ~ dnorm(0,0.386)
##     }
##     }
##     
##     #Observation group prior
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive check
##     #fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 626374
##    Total graph size: 1498331
## 
## Initializing model
## 
##      user    system   elapsed 
## 14531.605    75.001 14765.189

Assess Convergence

Effect of season on interaction probabilities

Dissimilairty in interactions (Beta_WN from Poisot 2012) Dashed line is the observed network from the time-series.

Note that this is really a measure of dissimilairty in one level (hummimngbirds), as the dissimilarity in plants is fixed by the sampling protocol. While there be a correlation between the species pool and the chosen plant to film, this is filtered by a human placing a camera at that plant, and as such isn’t a true measure of plant dissimiality.

Model overlap

Create a kind of venn diagram on PCA of model similarity based on per link discrepency.

## # A tibble: 16 x 3
## # Groups:   Model [4]
##    Model                      mean pair                                   
##    <chr>                     <dbl> <chr>                                  
##  1 Species_Detect           -0.951 Booted Racket-tail_Stromanthe stromant…
##  2 Species_Detect_Elevation -0.922 Booted Racket-tail_Stromanthe stromant…
##  3 Species                  -0.920 Booted Racket-tail_Stromanthe stromant…
##  4 Species_Detect_Elevation -0.911 Brown Inca_Psammisia aberrans          
##  5 Species_Detect           -0.909 Brown Inca_Psammisia aberrans          
##  6 Species                  -0.878 Brown Inca_Psammisia aberrans          
##  7 Species_Detect           -0.869 Violet-tailed Sylph_Begonia longirostr…
##  8 Species_Detect           -0.850 Violet-tailed Sylph_Drymonia tenuis    
##  9 Species_Detect_Elevation -0.840 Violet-tailed Sylph_Kohleria affinis   
## 10 Species                  -0.826 Violet-tailed Sylph_Kohleria affinis   
## 11 Species_Detect_Elevation -0.810 Violet-tailed Sylph_Begonia longirostr…
## 12 Species                  -0.809 Violet-tailed Sylph_Drymonia tenuis    
## 13 Random                   -0.562 Hoary Puffleg_Begonia longirostris     
## 14 Random                   -0.550 Sparkling Violetear_Centropogon solani…
## 15 Random                   -0.548 Booted Racket-tail_Stromanthe stromant…
## 16 Random                   -0.542 Collared Inca_Centropogon solanifolius

Without random model